import { getTableData } from '@/api/page'

export default {
    name: "component-page",
    components: {
    },
    data () {
        return {
            exportLoading: false,
            formData: {
                pageNum: 1,//当前页
                pageSize: 10,//每页显示条数
            },
            typeList: [],
            tableData: {
                loading: false,
                border: true,
                // 操作
                tableOption: {
                    label: '操作',
                    width: 120,
                    slot: true,
                },
                // 请求回来的数据
                tableData: [],
                // 列
                tableLabel: [],
                // 分页
                page: {
                    layout: 'total, sizes, prev, pager, next, jumper',
                    pageSizes: [10, 20, 30, 50, 100],
                    align: 'right', total: 1, size: 10, currentPage: 1,
                    currentChange: (currentPage) => {
                        this.$nextTick(() => {
                            this.formData.pageNum = currentPage;
                            this.searchForm();
                        })
                    },
                    sizeChange: (val) => {// 不需要可去掉
                        this.$nextTick(() => {
                            this.formData.pageSize = val;
                            this.searchForm();
                        })
                    }
                },
                selectionChange: (params) => {
                    this.ids = [];
                    params.map(item => this.ids.push(item.id));
                    this.formData.ruleCode = this.ids.toString();
                },
            },
            //   业务领域
            domainList: [],
            ids: [],
            deptList: [],
            statusList: [{
                label: '最新',
                value: 1
            }, {
                label: '历史',
                value: 0
            }],
        }
    },
    created () {
        this.labelInit();
    },
    watch: {
    },
    computed: {
    },
    methods: {
        initSearchForm () {
            this.formData = {
                pageNum: 1,
                pageSize: 10
            }
            this.searchForm()
        },
        // 重置表单数据
        resetForm () {
            this.formData = {
                pageNum: 1,
                pageSize: 10
            }
        },
        // 列初始化
        labelInit () {
            this.tableData.tableLabel = [
                { type: 'selection', width: 40, fixed: 'left', align: 'center' },
                { type: 'index', title: '序号', fixed: 'left', width: 60, align: 'center' },
                { prop: 'number', minWidth: 200, title: '客户号', tooltip: true, align: 'center' },
                { prop: 'name', minWidth: 160, title: '客户姓名', tooltip: true, align: 'center' },
                { prop: 'type', minWidth: 160, title: '客户类型', tooltip: true, align: 'center' },
                { prop: 'type', minWidth: 160, title: '证件类型', tooltip: true, align: 'center' },
                { prop: 'code', minWidth: 160, title: '证件号码', tooltip: true, align: 'center' },
                { prop: 'name', minWidth: 160, title: '客户地址', tooltip: true, align: 'center' },
            ];
        },
        // 数据初始化
        searchForm () {
            let search = { ... this.formData }
            //   this.tableData.loading = true;
            this.tableData.tableData = [{ number: '123456789', name: '客户名字', type: '类型', code: '15272829192y3539232' }, { number: '123456789', name: '客户名字', type: '类型', code: '15272829192y3539232' }, { number: '123456789', name: '客户名字', type: '类型', code: '15272829192y3539232' }]
            getTableData(search)
                .then(res => {
                    this.tableData.loading = false
                    if (res.success) {
                        this.tableData.tableData = data.rows || []
                        this.tableData.total = data.totalRows || 0
                    } else {

                    }
                })
                .catch(err => {
                    this.tableData.loading = false
                })

        },
        // 导出
        handleExport () {
        },
        // 操作栏按钮
        handButton (rows) {

        },
    },

    mounted () {
    },

}